package fragments;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.wangjin.menu.R;

/**
 * Created by wangjin on 15/5/30.
 */
public class MesssageFragment extends ListFragment {

    private String[] messages = {"张三","李四","王五"};
    private adapter ad;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ad = new adapter();
        setListAdapter(ad);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.project_list,container,false);
        return v;
    }

    class adapter extends ArrayAdapter<String>{

        public adapter(){
            super(getActivity(),0,messages);
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            if(convertView == null){

                convertView = getActivity().getLayoutInflater().
                        inflate(R.layout.message_item, null);
                TextView t = (TextView)convertView.findViewById(R.id.textView2);
                t.setText(messages[position]);
                t = (TextView) convertView.findViewById(R.id.textView6);
                t.setText("Can't wait to see you");
                t = (TextView)convertView.findViewById(R.id.textView7);
                t.setText("10:45 PM");
                return convertView;
            }else {
                return convertView;
            }
        }
    }
}
